/*
 * =====================================================================================
 *
 *        Filename:  Log.cc
 *
 *        Description:  
 *
 *        Version:  1.0
 *        Created:  12/23/21 16:57:27
 *
 *        Author:  XXXX (), XXXX
 *        Company:  XXXX
 *        Copyright:  Copyright 2021, XXXX
 *
 * =====================================================================================
 */

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdarg.h>

#include "Log.h"

#define LOG_BUF_SIZE 128

static int gLogLevel = LOG_D;

int LogPrint(int level, const char* tag, const char *func, const int line, const char* fmt, ...) {
      if (LOG_LEVEL > level) {
          return 0;
      }
      va_list ap;
      char buf[LOG_BUF_SIZE];
      char buf2[LOG_BUF_SIZE];

      va_start(ap, fmt);
      vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
	  snprintf(buf2, LOG_BUF_SIZE - 1, "%s %s %d:%s", tag, func, line, buf);
      va_end(ap);

	  printf("%s\n", buf2);

	  return 0;

  }


int LogSetLevel(int level) {
	gLogLevel = level;
	return 0;
}

